@ibiz-template-plugin/ibiz-file-previewer 0.0.28 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js
CHANGED
|
@@ -151,7 +151,7 @@ function O(n2, u2, t2, i2, o2, r2, e2, f2, c2, s2) {
|
|
|
151
151
|
else u2.__e = t2.__e, u2.__k = t2.__k, n3.then || z$1(u2);
|
|
152
152
|
l$3.__e(n3, u2, t2);
|
|
153
153
|
}
|
|
154
|
-
else null == r2 && u2.__v == t2.__v ? (u2.__k = t2.__k, u2.__e = t2.__e) : f2 = u2.__e = q$
|
|
154
|
+
else null == r2 && u2.__v == t2.__v ? (u2.__k = t2.__k, u2.__e = t2.__e) : f2 = u2.__e = q$2(t2.__e, u2, t2, i2, o2, r2, e2, c2, s2);
|
|
155
155
|
return (a2 = l$3.diffed) && a2(u2), 128 & u2.__u ? void 0 : f2;
|
|
156
156
|
}
|
|
157
157
|
function z$1(n2) {
|
|
@@ -172,7 +172,7 @@ function N$1(n2, u2, t2) {
|
|
|
172
172
|
function V$1(n2) {
|
|
173
173
|
return "object" != typeof n2 || null == n2 || n2.__b && n2.__b > 0 ? n2 : d$3(n2) ? n2.map(V$1) : w$2({}, n2);
|
|
174
174
|
}
|
|
175
|
-
function q$
|
|
175
|
+
function q$2(u2, t2, i2, o2, r2, e2, f2, c2, s2) {
|
|
176
176
|
var a2, h2, v2, y2, w2, _2, m2, b2 = i2.props || p$3, k2 = t2.props, x2 = t2.type;
|
|
177
177
|
if ("svg" == x2 ? r2 = "http://www.w3.org/2000/svg" : "math" == x2 ? r2 = "http://www.w3.org/1998/Math/MathML" : r2 || (r2 = "http://www.w3.org/1999/xhtml"), null != e2) {
|
|
178
178
|
for (a2 = 0; a2 < e2.length; a2++) if ((w2 = e2[a2]) && "setAttribute" in w2 == !!x2 && (x2 ? w2.localName == x2 : 3 == w2.nodeType)) {
|
|
@@ -303,6 +303,11 @@ function T$1(n2, r2) {
|
|
|
303
303
|
var u2 = p$2(t$1++, 7);
|
|
304
304
|
return C(u2.__H, r2) && (u2.__ = n2(), u2.__H = r2, u2.__h = n2), u2.__;
|
|
305
305
|
}
|
|
306
|
+
function q$1(n2, t2) {
|
|
307
|
+
return o$1 = 8, T$1(function() {
|
|
308
|
+
return n2;
|
|
309
|
+
}, t2);
|
|
310
|
+
}
|
|
306
311
|
function j$1() {
|
|
307
312
|
for (var n2; n2 = f$2.shift(); ) if (n2.__P && n2.__H) try {
|
|
308
313
|
n2.__H.__h.forEach(z), n2.__H.__h.forEach(B$1), n2.__H.__h = [];
|
|
@@ -2135,6 +2140,8 @@ const LoaddingSvg = (props) => {
|
|
|
2135
2140
|
}
|
|
2136
2141
|
);
|
|
2137
2142
|
};
|
|
2143
|
+
const FullScreenSvg = () => /* @__PURE__ */ u("svg", { viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ u("path", { d: "M547.4 197.4v46l200.3 0.1L546.1 444l32.4 32.6 201.9-200.7v200.9h46V197.5zM471.4 584.4l-32.6-32.6L243.6 747V547.9h-46v278.7h279v-46H275z" }) });
|
|
2144
|
+
const CloseFullScreenSvg = () => /* @__PURE__ */ u("svg", { viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ u("path", { d: "M544 480V282.944h52.224l0.064 107.968L763.072 224l36.928 36.928-166.976 166.976 108.032-0.128V480H544zM260.928 800l-36.928-36.928 166.912-166.784-107.968-0.064V544H480v197.056h-52.224l0.064-107.968L260.928 800z" }) });
|
|
2138
2145
|
function g(n2, t2) {
|
|
2139
2146
|
for (var e2 in t2) n2[e2] = t2[e2];
|
|
2140
2147
|
return n2;
|
|
@@ -17094,7 +17101,9 @@ const FilePreviewMD = (props) => {
|
|
|
17094
17101
|
value: initValue,
|
|
17095
17102
|
after: () => {
|
|
17096
17103
|
onPreview();
|
|
17097
|
-
|
|
17104
|
+
requestIdleCallback(() => {
|
|
17105
|
+
props.onInitialization();
|
|
17106
|
+
});
|
|
17098
17107
|
if (isLongContent) {
|
|
17099
17108
|
const remaining = content.substring(MAX_INIT_LENGTH);
|
|
17100
17109
|
const chunks = [];
|
|
@@ -19811,7 +19820,75 @@ const FilePreviewImageGroup = (props) => {
|
|
|
19811
19820
|
] }) })
|
|
19812
19821
|
] });
|
|
19813
19822
|
};
|
|
19823
|
+
const getFullscreenElement = () => {
|
|
19824
|
+
var _a, _b, _c;
|
|
19825
|
+
return (_c = (_b = (_a = document.fullscreenElement) != null ? _a : document.webkitFullscreenElement) != null ? _b : document.msFullscreenElement) != null ? _c : null;
|
|
19826
|
+
};
|
|
19827
|
+
const useFullscreen = (targetRef) => {
|
|
19828
|
+
const [isFullscreen, setIsFullscreen] = d$2(
|
|
19829
|
+
() => Boolean(getFullscreenElement())
|
|
19830
|
+
);
|
|
19831
|
+
y$1(() => {
|
|
19832
|
+
const handleChange = () => {
|
|
19833
|
+
setIsFullscreen(Boolean(getFullscreenElement()));
|
|
19834
|
+
};
|
|
19835
|
+
document.addEventListener("fullscreenchange", handleChange);
|
|
19836
|
+
document.addEventListener("webkitfullscreenchange", handleChange);
|
|
19837
|
+
document.addEventListener("MSFullscreenChange", handleChange);
|
|
19838
|
+
return () => {
|
|
19839
|
+
document.removeEventListener("fullscreenchange", handleChange);
|
|
19840
|
+
document.removeEventListener("webkitfullscreenchange", handleChange);
|
|
19841
|
+
document.removeEventListener("MSFullscreenChange", handleChange);
|
|
19842
|
+
};
|
|
19843
|
+
}, []);
|
|
19844
|
+
const enter = q$1(async () => {
|
|
19845
|
+
var _a;
|
|
19846
|
+
const el = (_a = targetRef == null ? void 0 : targetRef.current) != null ? _a : document.documentElement;
|
|
19847
|
+
if (!el) return false;
|
|
19848
|
+
try {
|
|
19849
|
+
if (el.requestFullscreen) {
|
|
19850
|
+
await el.requestFullscreen();
|
|
19851
|
+
} else if (el.webkitRequestFullscreen) {
|
|
19852
|
+
await el.webkitRequestFullscreen();
|
|
19853
|
+
} else if (el.msRequestFullscreen) {
|
|
19854
|
+
await el.msRequestFullscreen();
|
|
19855
|
+
} else {
|
|
19856
|
+
return false;
|
|
19857
|
+
}
|
|
19858
|
+
return true;
|
|
19859
|
+
} catch (error2) {
|
|
19860
|
+
console.error("进入全屏失败", error2);
|
|
19861
|
+
return false;
|
|
19862
|
+
}
|
|
19863
|
+
}, [targetRef]);
|
|
19864
|
+
const exit = q$1(async () => {
|
|
19865
|
+
if (!getFullscreenElement()) return true;
|
|
19866
|
+
try {
|
|
19867
|
+
if (document.exitFullscreen) {
|
|
19868
|
+
await document.exitFullscreen();
|
|
19869
|
+
} else if (document.webkitExitFullscreen) {
|
|
19870
|
+
await document.webkitExitFullscreen();
|
|
19871
|
+
} else if (document.msExitFullscreen) {
|
|
19872
|
+
await document.msExitFullscreen();
|
|
19873
|
+
}
|
|
19874
|
+
return true;
|
|
19875
|
+
} catch (error2) {
|
|
19876
|
+
console.error("退出全屏失败", error2);
|
|
19877
|
+
return false;
|
|
19878
|
+
}
|
|
19879
|
+
}, []);
|
|
19880
|
+
const toggle = q$1(async () => {
|
|
19881
|
+
if (getFullscreenElement()) {
|
|
19882
|
+
await exit();
|
|
19883
|
+
} else {
|
|
19884
|
+
await enter();
|
|
19885
|
+
}
|
|
19886
|
+
}, [enter, exit]);
|
|
19887
|
+
return { isFullscreen, enter, exit, toggle };
|
|
19888
|
+
};
|
|
19814
19889
|
const FilePreviewShell = (props) => {
|
|
19890
|
+
const containerRef = A(null);
|
|
19891
|
+
const { isFullscreen, toggle } = useFullscreen(containerRef);
|
|
19815
19892
|
y$1(() => {
|
|
19816
19893
|
document.addEventListener("click", handleClickOutside, true);
|
|
19817
19894
|
return () => {
|
|
@@ -19858,97 +19935,113 @@ const FilePreviewShell = (props) => {
|
|
|
19858
19935
|
break;
|
|
19859
19936
|
}
|
|
19860
19937
|
};
|
|
19861
|
-
return /* @__PURE__ */ u(
|
|
19862
|
-
|
|
19863
|
-
|
|
19864
|
-
|
|
19865
|
-
|
|
19866
|
-
|
|
19938
|
+
return /* @__PURE__ */ u(
|
|
19939
|
+
"div",
|
|
19940
|
+
{
|
|
19941
|
+
ref: containerRef,
|
|
19942
|
+
className: "file-preview-shell ".concat(state.value.theme),
|
|
19943
|
+
children: [
|
|
19944
|
+
/* @__PURE__ */ u("div", { className: "preview-header", children: [
|
|
19945
|
+
/* @__PURE__ */ u("div", { className: "file-info", children: [
|
|
19946
|
+
/* @__PURE__ */ u("h3", { className: "file-name", children: state.value.fileName }),
|
|
19947
|
+
/* @__PURE__ */ u("div", { className: "engine-container", children: [
|
|
19948
|
+
/* @__PURE__ */ u("div", { className: "engine-content", children: [
|
|
19949
|
+
/* @__PURE__ */ u(
|
|
19950
|
+
"div",
|
|
19951
|
+
{
|
|
19952
|
+
className: "engine-type ".concat(state.value.engineOptions.length > 1 ? "is-multiple" : ""),
|
|
19953
|
+
children: state.value.engineType
|
|
19954
|
+
}
|
|
19955
|
+
),
|
|
19956
|
+
state.value.engineOptions.length > 1 && /* @__PURE__ */ u(
|
|
19957
|
+
"div",
|
|
19958
|
+
{
|
|
19959
|
+
className: "engine-icon",
|
|
19960
|
+
onClick: () => {
|
|
19961
|
+
showwEngineOptions();
|
|
19962
|
+
},
|
|
19963
|
+
children: /* @__PURE__ */ u(DownSvg, {})
|
|
19964
|
+
}
|
|
19965
|
+
)
|
|
19966
|
+
] }),
|
|
19967
|
+
showEngineMenu.value && state.value.engineOptions.length > 1 && /* @__PURE__ */ u("ul", { className: "engine-options", children: state.value.engineOptions.map((type) => /* @__PURE__ */ u(
|
|
19968
|
+
"li",
|
|
19969
|
+
{
|
|
19970
|
+
className: "engine-option-item ".concat(type === state.value.engineType ? "is-active" : ""),
|
|
19971
|
+
onClick: () => {
|
|
19972
|
+
handleEngineOptionSelect(type);
|
|
19973
|
+
},
|
|
19974
|
+
children: type
|
|
19975
|
+
}
|
|
19976
|
+
)) })
|
|
19977
|
+
] })
|
|
19978
|
+
] }),
|
|
19979
|
+
/* @__PURE__ */ u("div", { className: "preview-controls", children: [
|
|
19980
|
+
/* @__PURE__ */ u("div", { className: "custom-controls", id: controller.controlsId }),
|
|
19867
19981
|
/* @__PURE__ */ u(
|
|
19868
|
-
"
|
|
19982
|
+
"button",
|
|
19869
19983
|
{
|
|
19870
|
-
className: "
|
|
19871
|
-
|
|
19984
|
+
className: "control-btn",
|
|
19985
|
+
onClick: toggle,
|
|
19986
|
+
title: isFullscreen ? "退出全屏" : "全屏",
|
|
19987
|
+
children: isFullscreen ? /* @__PURE__ */ u(CloseFullScreenSvg, {}) : /* @__PURE__ */ u(FullScreenSvg, {})
|
|
19872
19988
|
}
|
|
19873
19989
|
),
|
|
19874
|
-
|
|
19875
|
-
"
|
|
19990
|
+
/* @__PURE__ */ u(
|
|
19991
|
+
"button",
|
|
19876
19992
|
{
|
|
19877
|
-
className: "
|
|
19993
|
+
className: "control-btn download-btn",
|
|
19994
|
+
title: "下载选项",
|
|
19878
19995
|
onClick: () => {
|
|
19879
|
-
|
|
19996
|
+
showDownloadOptions();
|
|
19880
19997
|
},
|
|
19881
|
-
children: /* @__PURE__ */ u(
|
|
19998
|
+
children: /* @__PURE__ */ u("span", { className: "icon", children: /* @__PURE__ */ u(DownLoadSvg, {}) })
|
|
19882
19999
|
}
|
|
19883
20000
|
)
|
|
19884
|
-
] })
|
|
19885
|
-
|
|
19886
|
-
|
|
20001
|
+
] })
|
|
20002
|
+
] }),
|
|
20003
|
+
showDownloadMenu.value && /* @__PURE__ */ u("div", { className: "download-options", children: [
|
|
20004
|
+
state.value.fileContent === "" && /* @__PURE__ */ u(
|
|
20005
|
+
"button",
|
|
20006
|
+
{
|
|
20007
|
+
className: "download-option",
|
|
20008
|
+
onClick: (event) => {
|
|
20009
|
+
handDownLoad(ActionType.DOWNORIGINAL, event);
|
|
20010
|
+
},
|
|
20011
|
+
children: "下载原文件"
|
|
20012
|
+
}
|
|
20013
|
+
),
|
|
20014
|
+
state.value.engineType !== EngineType.PDF && /* @__PURE__ */ u(
|
|
20015
|
+
"button",
|
|
19887
20016
|
{
|
|
19888
|
-
className: "
|
|
19889
|
-
onClick: () => {
|
|
19890
|
-
|
|
20017
|
+
className: "download-option",
|
|
20018
|
+
onClick: (event) => {
|
|
20019
|
+
handDownLoad(ActionType.COPYTEXTCONTENT, event);
|
|
19891
20020
|
},
|
|
19892
|
-
children:
|
|
20021
|
+
children: "复制文本内容"
|
|
20022
|
+
}
|
|
20023
|
+
)
|
|
20024
|
+
] }),
|
|
20025
|
+
/* @__PURE__ */ u("div", { className: "preview-content", children: [
|
|
20026
|
+
/* @__PURE__ */ u(
|
|
20027
|
+
"div",
|
|
20028
|
+
{
|
|
20029
|
+
className: "preview-inner ".concat(controller.state.value.engineType.toLowerCase(), "-engine"),
|
|
20030
|
+
children: state.value.isCreated && controller.preViewComp && controller.preViewController ? _$2(controller.preViewComp, {
|
|
20031
|
+
controller: controller.preViewController,
|
|
20032
|
+
onInitialization: () => {
|
|
20033
|
+
var _a, _b;
|
|
20034
|
+
controller.updateState({ isLoading: false });
|
|
20035
|
+
(_b = (_a = controller.getOptions()).onInitialized) == null ? void 0 : _b.call(_a);
|
|
20036
|
+
}
|
|
20037
|
+
}) : null
|
|
19893
20038
|
}
|
|
19894
|
-
)
|
|
20039
|
+
),
|
|
20040
|
+
state.value.isLoading && /* @__PURE__ */ u(Loading, { size: 48 })
|
|
19895
20041
|
] })
|
|
19896
|
-
]
|
|
19897
|
-
|
|
19898
|
-
|
|
19899
|
-
/* @__PURE__ */ u(
|
|
19900
|
-
"button",
|
|
19901
|
-
{
|
|
19902
|
-
className: "control-btn download-btn",
|
|
19903
|
-
title: "下载选项",
|
|
19904
|
-
onClick: () => {
|
|
19905
|
-
showDownloadOptions();
|
|
19906
|
-
},
|
|
19907
|
-
children: /* @__PURE__ */ u("span", { className: "icon", children: /* @__PURE__ */ u(DownLoadSvg, {}) })
|
|
19908
|
-
}
|
|
19909
|
-
)
|
|
19910
|
-
] })
|
|
19911
|
-
] }),
|
|
19912
|
-
showDownloadMenu.value && /* @__PURE__ */ u("div", { className: "download-options", children: [
|
|
19913
|
-
state.value.fileContent === "" && /* @__PURE__ */ u(
|
|
19914
|
-
"button",
|
|
19915
|
-
{
|
|
19916
|
-
className: "download-option",
|
|
19917
|
-
onClick: (event) => {
|
|
19918
|
-
handDownLoad(ActionType.DOWNORIGINAL, event);
|
|
19919
|
-
},
|
|
19920
|
-
children: "下载原文件"
|
|
19921
|
-
}
|
|
19922
|
-
),
|
|
19923
|
-
state.value.engineType !== EngineType.PDF && /* @__PURE__ */ u(
|
|
19924
|
-
"button",
|
|
19925
|
-
{
|
|
19926
|
-
className: "download-option",
|
|
19927
|
-
onClick: (event) => {
|
|
19928
|
-
handDownLoad(ActionType.COPYTEXTCONTENT, event);
|
|
19929
|
-
},
|
|
19930
|
-
children: "复制文本内容"
|
|
19931
|
-
}
|
|
19932
|
-
)
|
|
19933
|
-
] }),
|
|
19934
|
-
/* @__PURE__ */ u("div", { className: "preview-content", children: [
|
|
19935
|
-
/* @__PURE__ */ u(
|
|
19936
|
-
"div",
|
|
19937
|
-
{
|
|
19938
|
-
className: "preview-inner ".concat(controller.state.value.engineType.toLowerCase(), "-engine"),
|
|
19939
|
-
children: state.value.isCreated && controller.preViewComp && controller.preViewController ? _$2(controller.preViewComp, {
|
|
19940
|
-
controller: controller.preViewController,
|
|
19941
|
-
onInitialization: () => {
|
|
19942
|
-
var _a, _b;
|
|
19943
|
-
controller.updateState({ isLoading: false });
|
|
19944
|
-
(_b = (_a = controller.getOptions()).onInitialized) == null ? void 0 : _b.call(_a);
|
|
19945
|
-
}
|
|
19946
|
-
}) : null
|
|
19947
|
-
}
|
|
19948
|
-
),
|
|
19949
|
-
state.value.isLoading && /* @__PURE__ */ u(Loading, { size: 48 })
|
|
19950
|
-
] })
|
|
19951
|
-
] });
|
|
20042
|
+
]
|
|
20043
|
+
}
|
|
20044
|
+
);
|
|
19952
20045
|
};
|
|
19953
20046
|
class FilePreviewItemController {
|
|
19954
20047
|
/**
|
|
@@ -21226,8 +21319,8 @@ class FilePreviewShellController {
|
|
|
21226
21319
|
async updateView(data) {
|
|
21227
21320
|
this.updateState({ isCreated: false, isLoading: true });
|
|
21228
21321
|
await this.parseParams(data);
|
|
21229
|
-
await this.parsePreviewItem();
|
|
21230
21322
|
this.mountComponent();
|
|
21323
|
+
await this.parsePreviewItem();
|
|
21231
21324
|
this.updateState({ isCreated: true });
|
|
21232
21325
|
}
|
|
21233
21326
|
/**
|